#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int qian = 9 - (s[0] - '0');
  int bai = 9 - (s[1] - '0');
  int shi = 9 - (s[2] - '0');
  int ge = 9 - (s[3] - '0');

  cout << ge << shi << bai << qian;
  return 0;
}